package com.yan.demo;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Demo2 {
    public static void main(String[] args) throws ParseException {
        String date = "1991-10-24";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        // String --> Date
        Date parse = sdf.parse(date);
        // Date --> Calender
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(parse);
        // Calender + 1年
        calendar.add(Calendar.YEAR , 1);
        System.out.println(calendar);
        // Calendar --> Date
        Date time = calendar.getTime();
        System.out.println(time);
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
        String format = sdf2.format(time);
        System.out.println("format = " + format);
    }
}
